package com.cz.datafetcher.controller;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.cz.datafetcher.entity.FetchTypes;
import com.cz.datafetcher.service.FetchTypesService;
import io.swagger.annotations.Api;
import org.apache.commons.lang3.StringUtils;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@Api(tags = "数据类型")
@RequestMapping("/fetchtypes")
public class FetchTypesController
        extends SingleTabControllerBase<FetchTypes, Integer, FetchTypesService, FetchTypes>
{
    @Override
    protected QueryWrapper<FetchTypes> buildQueryWrapper(FetchTypes fetchTypes) {
        QueryWrapper<FetchTypes> qw = new QueryWrapper<>();
        qw.lambda()
                .like(StringUtils.isNotBlank(fetchTypes.getName()), FetchTypes::getName,fetchTypes.getName());
        return qw;
    }

    @Override
    protected Integer getKeyFromObj(FetchTypes fetchTypes) {
        return fetchTypes.getId();
    }
}
